package com.ohuang.apkMerge

import com.google.gson.Gson
import java.io.File

fun main() {
    copyRes("C:\\Users\\ali213\\Desktop\\测试\\test\\res\\drawable-ldpi"
    ,"C:\\Users\\ali213\\Desktop\\测试"
    , callBack = {a,b->
            println("$b 已存在  不复制$a")
        })


}

fun findAndDelete(path: String, dir: String, fileName: String) {

    var file = File(path)
    file.listFiles()?.forEach { file0 ->
        if (file0.isDirectory) {
            if (file0.name.contains(dir)) {
                file0.listFiles()?.forEach {
                    if (it.nameWithoutExtension == fileName) {
                        println(it.path)
                        it.delete()

                    }
                }
            }
        }
    }
}




/**
 * 寻找res文件在哪个文件夹  如要寻找@drawable/new512文件再哪个文件夹下存在
 * path res文件路径
 * dir  在带有该字符串的文件夹下寻找   如 drawable
 * filename  文件名   如 new512
 */
fun findFileInPath(path: String, dir: String, fileName: String): ArrayList<String> {
    val arrayList = ArrayList<String>()
    var file = File(path)
    file.listFiles().forEach { file0 ->
        if (file0.isDirectory) {
            if (file0.name.contains(dir)) {
                file0.listFiles().forEach {
                    if (it.nameWithoutExtension == fileName) {
                        arrayList.add(file0.name)
                        println(it.path)
                    }
//                if (it.name.contains(fileName) ) {
//                    arrayList.add(file0.name)
//                    println(it.path)
//                }
                }
            }
        }
    }
    return arrayList
}





